package com.macaque.admin.sys.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.macaque.admin.sys.model.User;

@Controller
public class AdminController {
	
	@ResponseBody
	@RequestMapping(value = "/auth")
	public User auth(@RequestParam(value = "userName") String userName,HttpServletRequest request,
			@RequestParam(value = "password") String password,ModelMap modelMap) {
		if("test".equals(userName)&&"123".equals(password)){
			User curUser = new User();
			curUser.setUserName("tset");
			curUser.setPassword("123");
			request.getSession().setAttribute("curUser", curUser);
			return curUser;
		}else{
			return null;
		}
	}
	@RequestMapping(value = "index", method = RequestMethod.GET)
	public String index(HttpServletRequest request, ModelMap modelMap) {
		return "admin/index";
	}
	@RequestMapping(value = "login", method = RequestMethod.GET)
	public String adminLogin(HttpServletRequest request, ModelMap modelMap) {
		return "admin/login";
	}
}
